unit Unit31; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, Unit1, Unit27;

type

  { TForm31 }

  TForm31 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end; 

var
  Form31: TForm31; 

implementation

{ TForm31 }

procedure TForm31.FormShow(Sender: TObject);
begin
  Edit1.Text := '';
  Edit2.Text := '';

  Edit1.SetFocus;
end;

procedure TForm31.Button1Click(Sender: TObject);
begin
  Form27.ShowModal;
  Edit1.Text := Form27.codigo_producto;
end;

procedure TForm31.Button2Click(Sender: TObject);
var
  QueryString : String;
  
begin
  if (Edit1.Text <> '') and (Edit2.Text <> '') then
  begin
    QueryString := 'select alta_devolucion(''' + Edit1.Text + ''', ''' + Edit2.Text + ''', '
      + registro.codigo_sucursal + ')';

    Form1.PQConnection1.ExecuteDirect('begin work;');
    Form1.PQConnection1.ExecuteDirect(QueryString);
    Form1.PQConnection1.ExecuteDirect('commit work;');

    ShowMessage('ALTA EXITOSA');

    Close;
  end
  else
    ShowMessage('ERROR EN EL INGRESO DE DATOS');
end;

procedure TForm31.Button3Click(Sender: TObject);
begin
  Close;
end;

initialization
  {$I unit31.lrs}

end.

